﻿package threadTest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TreadPoolTest {

	public static void main(String[] args) {
		ExecutorService threadPool = Executors.newFixedThreadPool(10);
		class Some implements Callable{
			int age = 0;
			Some(int i){
				this.age = i;
			}
			public Object call() throws Exception {
				System.out.println(age);
				return null;
			}
			
		}
		List<Callable> tasks = new ArrayList();
		for(int i=0;i<1000;i++){
			tasks.add(new Some(i));
		}
		try{
			threadPool.invokeAll((Collection)tasks);
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
